/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ongmanager.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author wbettencourt
 */
@Entity
@Table(name = "ong")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ong.findAll", query = "SELECT o FROM Ong o"),
    @NamedQuery(name = "Ong.findByIdONG", query = "SELECT o FROM Ong o WHERE o.idONG = :idONG"),
    @NamedQuery(name = "Ong.findByNombre", query = "SELECT o FROM Ong o WHERE o.nombre = :nombre"),
    @NamedQuery(name = "Ong.findByCarpeta", query = "SELECT o FROM Ong o WHERE o.carpeta = :carpeta"),
    @NamedQuery(name = "Ong.findBySiglas", query = "SELECT o FROM Ong o WHERE o.siglas = :siglas"),
    @NamedQuery(name = "Ong.findByRif", query = "SELECT o FROM Ong o WHERE o.rif = :rif"),
    @NamedQuery(name = "Ong.findByFechaConstitucion", query = "SELECT o FROM Ong o WHERE o.fechaConstitucion = :fechaConstitucion"),
    @NamedQuery(name = "Ong.findByFiguraJuridica", query = "SELECT o FROM Ong o WHERE o.figuraJuridica = :figuraJuridica"),
    @NamedQuery(name = "Ong.findByObjetivos", query = "SELECT o FROM Ong o WHERE o.objetivos = :objetivos"),
    @NamedQuery(name = "Ong.findByActividades", query = "SELECT o FROM Ong o WHERE o.actividades = :actividades"),
    @NamedQuery(name = "Ong.findByUsuarioRegistro", query = "SELECT o FROM Ong o WHERE o.usuarioRegistro = :usuarioRegistro"),
    @NamedQuery(name = "Ong.findByEmailRegistro", query = "SELECT o FROM Ong o WHERE o.emailRegistro = :emailRegistro"),
    @NamedQuery(name = "Ong.findByObservaciones", query = "SELECT o FROM Ong o WHERE o.observaciones = :observaciones"),
    @NamedQuery(name = "Ong.findByCreatedAt", query = "SELECT o FROM Ong o WHERE o.createdAt = :createdAt")})
public class Ong implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IdONG")
    private Integer idONG;
    @Basic(optional = false)
    @Column(name = "Nombre")
    private String nombre;
    @Column(name = "Carpeta")
    private String carpeta;
    @Column(name = "Siglas")
    private String siglas;
    @Column(name = "RIF")
    private String rif;
    @Column(name = "FechaConstitucion")
    @Temporal(TemporalType.DATE)
    private Date fechaConstitucion;
    @Column(name = "FiguraJuridica")
    private String figuraJuridica;
    @Column(name = "Objetivos")
    private String objetivos;
    @Column(name = "Actividades")
    private String actividades;
    @Column(name = "UsuarioRegistro")
    private String usuarioRegistro;
    @Column(name = "EmailRegistro")
    private String emailRegistro;
    @Column(name = "Observaciones")
    private String observaciones;
    @Basic(optional = false)
    @Column(name = "created_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdAt;
    @ManyToMany(mappedBy = "ongList")
    private List<Beneficiario> beneficiarioList;
    @JoinTable(name = "ong_tipoatencion", joinColumns = {
        @JoinColumn(name = "IdOng", referencedColumnName = "IdONG")}, inverseJoinColumns = {
        @JoinColumn(name = "IdTipoAtencion", referencedColumnName = "IdTipoAtencion")})
    @ManyToMany
    private List<Tipoatencion> tipoatencionList;
    @JoinTable(name = "residencia", joinColumns = {
        @JoinColumn(name = "IdOng", referencedColumnName = "IdONG")}, inverseJoinColumns = {
        @JoinColumn(name = "IdPais", referencedColumnName = "IdPais")})
    @ManyToMany
    private List<Pais> paisList;
    @JoinTable(name = "ong_situacion", joinColumns = {
        @JoinColumn(name = "IdOng", referencedColumnName = "IdONG")}, inverseJoinColumns = {
        @JoinColumn(name = "IdSituacion", referencedColumnName = "IdSituacion")})
    @ManyToMany
    private List<Situacion> situacionList;
    @JoinTable(name = "influencia", joinColumns = {
        @JoinColumn(name = "IdOng", referencedColumnName = "IdONG")}, inverseJoinColumns = {
        @JoinColumn(name = "IdPais", referencedColumnName = "IdPais")})
    @ManyToMany
    private List<Pais> paisList1;
    @OneToMany(mappedBy = "supervisor")
    private List<Ong> ongList;
    @JoinColumn(name = "Supervisor", referencedColumnName = "IdONG")
    @ManyToOne
    private Ong supervisor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ong")
    private List<OngDocumento> ongDocumentoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idONG")
    private List<Contacto> contactoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ong")
    private List<StatusOng> statusOngList;

    public Ong() {
    }

    public Ong(Integer idONG) {
        this.idONG = idONG;
    }

    public Ong(Integer idONG, String nombre, Date createdAt) {
        this.idONG = idONG;
        this.nombre = nombre;
        this.createdAt = createdAt;
    }

    public Integer getIdONG() {
        return idONG;
    }

    public void setIdONG(Integer idONG) {
        Integer oldIdONG = this.idONG;
        this.idONG = idONG;
        changeSupport.firePropertyChange("idONG", oldIdONG, idONG);
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        String oldNombre = this.nombre;
        this.nombre = nombre;
        changeSupport.firePropertyChange("nombre", oldNombre, nombre);
    }

    public String getCarpeta() {
        return carpeta;
    }

    public void setCarpeta(String carpeta) {
        String oldCarpeta = this.carpeta;
        this.carpeta = carpeta;
        changeSupport.firePropertyChange("carpeta", oldCarpeta, carpeta);
    }

    public String getSiglas() {
        return siglas;
    }

    public void setSiglas(String siglas) {
        String oldSiglas = this.siglas;
        this.siglas = siglas;
        changeSupport.firePropertyChange("siglas", oldSiglas, siglas);
    }

    public String getRif() {
        return rif;
    }

    public void setRif(String rif) {
        String oldRif = this.rif;
        this.rif = rif;
        changeSupport.firePropertyChange("rif", oldRif, rif);
    }

    public Date getFechaConstitucion() {
        return fechaConstitucion;
    }

    public void setFechaConstitucion(Date fechaConstitucion) {
        Date oldFechaConstitucion = this.fechaConstitucion;
        this.fechaConstitucion = fechaConstitucion;
        changeSupport.firePropertyChange("fechaConstitucion", oldFechaConstitucion, fechaConstitucion);
    }

    public String getFiguraJuridica() {
        return figuraJuridica;
    }

    public void setFiguraJuridica(String figuraJuridica) {
        String oldFiguraJuridica = this.figuraJuridica;
        this.figuraJuridica = figuraJuridica;
        changeSupport.firePropertyChange("figuraJuridica", oldFiguraJuridica, figuraJuridica);
    }

    public String getObjetivos() {
        return objetivos;
    }

    public void setObjetivos(String objetivos) {
        String oldObjetivos = this.objetivos;
        this.objetivos = objetivos;
        changeSupport.firePropertyChange("objetivos", oldObjetivos, objetivos);
    }

    public String getActividades() {
        return actividades;
    }

    public void setActividades(String actividades) {
        String oldActividades = this.actividades;
        this.actividades = actividades;
        changeSupport.firePropertyChange("actividades", oldActividades, actividades);
    }

    public String getUsuarioRegistro() {
        return usuarioRegistro;
    }

    public void setUsuarioRegistro(String usuarioRegistro) {
        String oldUsuarioRegistro = this.usuarioRegistro;
        this.usuarioRegistro = usuarioRegistro;
        changeSupport.firePropertyChange("usuarioRegistro", oldUsuarioRegistro, usuarioRegistro);
    }

    public String getEmailRegistro() {
        return emailRegistro;
    }

    public void setEmailRegistro(String emailRegistro) {
        String oldEmailRegistro = this.emailRegistro;
        this.emailRegistro = emailRegistro;
        changeSupport.firePropertyChange("emailRegistro", oldEmailRegistro, emailRegistro);
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        String oldObservaciones = this.observaciones;
        this.observaciones = observaciones;
        changeSupport.firePropertyChange("observaciones", oldObservaciones, observaciones);
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        Date oldCreatedAt = this.createdAt;
        this.createdAt = createdAt;
        changeSupport.firePropertyChange("createdAt", oldCreatedAt, createdAt);
    }

    @XmlTransient
    public List<Beneficiario> getBeneficiarioList() {
        return beneficiarioList;
    }

    public void setBeneficiarioList(List<Beneficiario> beneficiarioList) {
        this.beneficiarioList = beneficiarioList;
    }

    @XmlTransient
    public List<Tipoatencion> getTipoatencionList() {
        return tipoatencionList;
    }

    public void setTipoatencionList(List<Tipoatencion> tipoatencionList) {
        this.tipoatencionList = tipoatencionList;
    }

    @XmlTransient
    public List<Pais> getPaisList() {
        return paisList;
    }

    public void setPaisList(List<Pais> paisList) {
        this.paisList = paisList;
    }

    @XmlTransient
    public List<Situacion> getSituacionList() {
        return situacionList;
    }

    public void setSituacionList(List<Situacion> situacionList) {
        this.situacionList = situacionList;
    }

    @XmlTransient
    public List<Pais> getPaisList1() {
        return paisList1;
    }

    public void setPaisList1(List<Pais> paisList1) {
        this.paisList1 = paisList1;
    }

    @XmlTransient
    public List<Ong> getOngList() {
        return ongList;
    }

    public void setOngList(List<Ong> ongList) {
        this.ongList = ongList;
    }

    public Ong getSupervisor() {
        return supervisor;
    }

    public void setSupervisor(Ong supervisor) {
        Ong oldSupervisor = this.supervisor;
        this.supervisor = supervisor;
        changeSupport.firePropertyChange("supervisor", oldSupervisor, supervisor);
    }

    @XmlTransient
    public List<OngDocumento> getOngDocumentoList() {
        return ongDocumentoList;
    }

    public void setOngDocumentoList(List<OngDocumento> ongDocumentoList) {
        this.ongDocumentoList = ongDocumentoList;
    }

    @XmlTransient
    public List<Contacto> getContactoList() {
        return contactoList;
    }

    public void setContactoList(List<Contacto> contactoList) {
        this.contactoList = contactoList;
    }

    @XmlTransient
    public List<StatusOng> getStatusOngList() {
        return statusOngList;
    }

    public void setStatusOngList(List<StatusOng> statusOngList) {
        this.statusOngList = statusOngList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idONG != null ? idONG.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ong)) {
            return false;
        }
        Ong other = (Ong) object;
        if ((this.idONG == null && other.idONG != null) || (this.idONG != null && !this.idONG.equals(other.idONG))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ongmanager.model.Ong[ idONG=" + idONG + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
